package com.example.caffeinecache01.controller;

import com.example.caffeinecache01.entity.User;
import com.example.caffeinecache01.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @Autowired
    CacheManager cacheManager;

    @PostMapping("/getuserbyname")
    public List<User> getUserByName(@RequestBody User user){
        System.out.println("------------");
        System.out.println("call  /getuserbyname");
        List<User> users = userService.getUserByName(user.getName());
        return users;

    }

    @GetMapping("/hehe")
    public String hehe(){
        return "hehhehhehe";
    }

    @PostMapping("/he")
    public String he(){
        log.info("log 成功了 he ----------------------------------");
        return "ttt";
    }
}